<Project>

  <Import Project="..\..\Directory.Build.targets" />

  <ItemGroup Condition="'$(UsingMicrosoftNoTargetsSdk)' != 'true'">
    <_DebugSymbolToMove Include="@(DebugSymbolsProjectOutputGroupOutput->Metadata('FinalOutputPath'))"
                        FolderName="$([System.IO.Directory]::GetParent('%(Identity)').Name)" />
    <_DebugSymbolToMoveToExclude Include="@(_DebugSymbolToMove->WithMetadataValue('FolderName', 'aotsdk'))" />
    <_DebugSymbolToMoveToUpdate Include="@(_DebugSymbolToMove)"
                                Exclude="@(_DebugSymbolToMoveToExclude)" />
    <!-- Remove the FolderName metadata for projects that don't reside under an aotsdk folder. -->
    <_DebugSymbolToMove Update="@(_DebugSymbolToMoveToUpdate)"
                        FolderName="" />
    <_DebugSymbolToMove Update="@(_DebugSymbolToMove)"
                        Destination="$(RuntimeBinDir)PDB\%(FolderName)\%(Filename)%(Extension)" />
  </ItemGroup>

  <!-- Consolidate all PDBs into a single location, except the aotsdk PDBs, as S.P.C will overwrite the coreclr PDBs. -->
  <Target Name="MoveSymbolFiles"
          AfterTargets="CopyFilesToOutputDirectory"
          DependsOnTargets="_CheckForCompileOutputs"
          Inputs="@(_DebugSymbolToMove)"
          Outputs="@(_DebugSymbolToMove->Metadata('Destination'))"
          Condition="'$(_DebugSymbolsProduced)' == 'true'">
    <Copy SourceFiles="@(_DebugSymbolToMove)"
          DestinationFiles="@(_DebugSymbolToMove->Metadata('Destination'))"
          UseHardlinksIfPossible="false" />
  </Target>

  <!-- Import targets here to have TargetPath and other macros defined. Limit to CoreLib. -->
  <Import Condition="'$(MSBuildProjectName)' == 'System.Private.CoreLib' or '$(IsNativeAotProject)' == 'true'" Project="$(RepositoryEngineeringDir)illink.targets" />
  <Import Project="$(RepositoryEngineeringDir)liveILLink.targets" />

</Project>
